import os.path
import time
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://sahitest.com/demo/iframesTest.htm")
time.sleep(2)
driver.find_element(By.ID, 'checkRecord').clear()
driver.find_element(By.ID, 'checkRecord').send_keys("xxxx")
time.sleep(3)
# 进入iframe
driver.switch_to.frame(0)
driver.find_element(By.ID, 'open-self').click()
# 退出iframe
driver.switch_to.parent_frame()
# 退到默认页
driver.switch_to.default_content()
time.sleep(3)
driver.close()
